package com.comp490.bullet;

import android.graphics.Canvas;
import android.graphics.Paint;

import com.comp490.shooter.GameView;
import com.comp490.sprite.Ship;

public class RoundBullet extends Bullet
{
    public RoundBullet(float x, float y, int damage, Paint paint, int radius,
            boolean active)
    {
        super(x, y, damage, active);
        this.paint = paint;
        this.radius = radius;
    }

    public boolean boundsCheck(GameView g)
    {
        return x > -radius && x < g.getWidth() + radius && y > -radius && y < g.getHeight() + radius ;
    }

    /**
     * Check to see if a collision has occurred. More specifically it checks if
     * 'this' object and the argument object are a certain distance away from
     * each other on the screen.
     * 
     * @param object
     *            object to check if it collided with 'this' object.
     * @return true if collision occurred, false otherwise.
     */
    public boolean collisionCheck(Ship object)
    {
        if(!active || !object.isActive())
            return false;
        float dx = x - object.getCenterBitmapX();
        float dy = y - object.getCenterBitmapY();
        return android.util.FloatMath.sqrt(dx * dx + dy * dy) < radius
                + object.collisionRadius();
    }

    public void draw(Canvas canvas)
    {
        if(active)
            canvas.drawCircle(x, y, radius, paint);
    }

    public float collisionRadius()
    {
        return radius;
    }
}